package cate.game.activity.convertfairy.msg;

import cate.common.annotation.OperationSetter;
import cate.common.table.d.GDOperation;
import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.activity.convertfairy.ConvertFairyActivity;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBFairyReplace;
import easy.java.dev.note.NoteField;

@ClientMsg(title = "置换灵器 的 请求")
public class ConvertFairyReq implements MsgInput {
    @NoteField("功能id")
    public int funcId;
    @NoteField("用于置换的灵器唯一id")
    public String uid;
    @NoteField("置换目标灵器id")
    public int tid;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        ConvertFairyActivity single;
        single = cc.getRole().getActivity().getEnableActivitySingle(funcId);
        if (single == null) {
            cc.getRole().getGame().notice.message(cc.getRole(), "活动未开启");
            return;
        }
        GameResult<ConvertFairyActivity> r = single.convert(uid, tid);
        if (!r.ok()) {
            game.notice.message(cc.getRole(), r.message);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBFairyReplace.EXE_REQ;
    }
}
